<template style="text-align:center;">
    <div >
        <Nuxt />
    </div>
</template>

<script>
export default {
    data(){
        return {
            hasconnected:false
        }
    },
    mounted() {
        if(this.hasconnect==false) {
          this.$socket.emit('shake_hand', 'Bearer ' + this.myToken)
          this.hasconnect = true
        }
    },
    sockets: {
    refused(message) {
      this.hasconnect = false
      this.$message('WebSocket拒绝连接')
      console.log('************', message)
    },
    accepted(message) {   
      console.log('************', message)
    },
    message({auth_id, admin, content, time}){
      console.log('收到消息',auth_id, admin, content, time)
    },
    connect() {
      if(this.hasconnect==false) {
        this.$socket.emit('shake_hand', 'Bearer ' + this.myToken)
        this.hasconnect = true
      }
    },
    disconnect(){
      this.hasconnect = false
    }
  }
}
</script>

<style>

</style>